
 export const EPlatform = {
 	/**App*/
 	AppPlus: "APP-PLUS",
 	/**App nvue*/
 	AppPlusNvue: "APP-PLUS-NVUE",
 	/**H5*/
 	H5: "H5",
 	/**微信小程序*/
 	MpWeixin: "MP-WEIXIN",
 	/**支付宝小程序*/
 	MpAlipay: "MP-ALIPAY",
 	/**百度小程序*/
 	MpBaidu: "MP-BAIDU",
 	/**字节跳动小程序*/
 	MpToutiao: "MP-TOUTIAO",
 	/**QQ小程序*/
 	MpQq: "MP-QQ",
 	/**360小程序*/
 	Mp360: "MP-360",
 	/**微信小程序/支付宝小程序/百度小程序/字节跳动小程序/QQ小程序/360小程序*/
 	Mp: "MP",
 	/**快应用通用(包含联盟、华为)*/
 	QuickappWebview: "quickapp-webview",
 	/**快应用联盟*/
 	QuickappWebviewUnion: "quickapp-webview-union",
 	/**快应用华为*/
 	QuickappWebviewHuawei: "quickapp-webview-huawei",
 }
 
 export const getPlatform = function(isAll) {
	let platform = "",
		values = [];

	//#ifdef APP-PLUS
	platform = EPlatform.AppPlus;
	values.push(platform);
	//#endif

	//#ifdef APP-PLUS-NVUE
	platform = EPlatform.AppPlusNvue;
	values.push(platform);
	//#endif

	//#ifdef H5
	platform = EPlatform.H5;
	values.push(platform);
	//#endif

	//#ifdef MP-WEIXIN
	platform = EPlatform.MpWeixin;
	values.push(platform);
	//#endif

	//#ifdef MP-ALIPAY
	platform = EPlatform.MpAlipay;
	values.push(platform);
	//#endif

	//#ifdef MP-BAIDU
	platform = EPlatform.MpBaidu;
	values.push(platform);
	//#endif

	//#ifdef MP-TOUTIAO
	platform = EPlatform.MpToutiao;
	values.push(platform);
	//#endif

	//#ifdef MP-QQ
	platform = EPlatform.MpQq;
	values.push(platform);
	//#endif

	//#ifdef MP-360
	platform = EPlatform.Mp360;
	values.push(platform);
	//#endif

	//#ifdef MP
	platform = EPlatform.Mp;
	values.push(platform);
	//#endif

	//#ifdef quickapp-webview
	platform = EPlatform.QuickappWebview;
	values.push(platform);
	//#endif

	//#ifdef quickapp-webview-union
	platform = EPlatform.QuickappWebviewUnion;
	values.push(platform);
	//#endif

	//#ifdef quickapp-webview-huawei
	platform = EPlatform.QuickappWebviewHuawei;
	values.push(platform);
	//#endif

	if (isAll) {
		return values;
	}
	return platform;
}


export const random_string = (len) =>{
	len = len || 32;
	var chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
	var maxPos = chars.length;
	var pwd = '';
	for (var i = 0; i < len; i++) {
		pwd += chars.charAt(Math.floor(Math.random() * maxPos));
	}
	return pwd;
}

export const prePage = () => {
	let pages = getCurrentPages();
	let prePage = pages[pages.length - 2];
	// #ifdef H5
	return prePage;
	// #endif
	return prePage.$vm;
}

export const get_suffix = (filename)=>{
	var pos = filename.lastIndexOf('.')
	var suffix = ''
	if (pos != -1) {
		suffix = filename.substring(pos)
	}
	return suffix;
}

export const getScrollHeight = (callback) => {
	uni.getSystemInfo({
		success: function(res) {
			var result = {
				scrollHeight: 0, //滚动栏高度
				capsuleButtonWidth: 0, //距离右侧胶囊距离
				isMiniapp: false,
			};
			var subHeight = res.platform == "ios" ? 48 : 45;
			result.isMiniapp = getPlatform() == EPlatform.Mp;
			result.scrollHeight = res.windowHeight - res.statusBarHeight - subHeight;

			if (result.isMiniapp) {
				var rect = uni.getMenuButtonBoundingClientRect();
				result.capsuleButtonWidth = rect.width + 20;
			}

			callback && callback(result);
		}
	});
}


export const navTo =  (url) =>  {
	console.log('22')
	if (!url) {
		// this.message("路径为空");
		return;
	}
	uni.navigateTo({
		url: url
	});
}